package com.us.usws.biz;

import net.iwsh.core.common.GlobalConfig;

import org.apache.commons.lang3.StringUtils;

public class ResourceURIReplacer {

	/**
	 * get channel picture url
	 * @param focusedChannelUid
	 * @return
	 */
	public static String getChannelPictureURL(String channelUid, String picutre) {
		//${Host/URL}/upload/grid/channel_pics/{channelUid}/{channelPicture}
		String ret = GlobalConfig.getString("CommonLinkURLs/ChannelPicture");
		ret = StringUtils.replace(ret, "{channelUid}", channelUid);
		ret = StringUtils.replace(ret, "{channelPicture}", picutre);
		return ret;
	}

	/**
	 * get video snapshot url
	 * @param videoFileUid
	 * @param videoFileSnapshot
	 * @return
	 */
	public static String getVideoSnapshotURL(String videoFileUid, String videoFileSnapshot) {
		//${Host/URL}/upload/grid/movie_files/{videoFileUid}/{videoFileSnapshot}
		String ret = GlobalConfig.getString("CommonLinkURLs/VideoSnapshot");
		ret = StringUtils.replace(ret, "{videoFileUid}", videoFileUid);
		ret = StringUtils.replace(ret, "{videoFileSnapshot}", videoFileSnapshot);
		return ret;
	}

	/**
	 * get user avatar
	 * @param avatar
	 * @return
	 */
	public static String getUserAvatar(String userUid, String avatar) {
		//
		String ret = GlobalConfig.getString("CommonLinkURLs/UserAvatar");
		ret = StringUtils.replace(ret, "{userUid}", userUid);
		ret = StringUtils.replace(ret, "{avatar}", avatar);
		return ret;
	}

	/**
	 * get video file url
	 * @param uid
	 * @return
	 */
	public static String getVideoFileURL(String videoFileUid, String videoFileExt) {
		String ret = GlobalConfig.getString("CommonLinkURLs/VideoFile");
		ret = StringUtils.replace(ret, "{videoFileUid}", videoFileUid);
		//ret = StringUtils.replace(ret, "{videoFileName}", videoFileName);
		ret = StringUtils.replace(ret, "{videoFileExt}", videoFileExt);
		return ret;
	}

	/**
	 * get meeting snapshot
	 * @param meetingUid
	 * @param meetingSnapshot
	 * @return
	 */
	public static String getMeetingSnapshotURL(String meetingUid, String meetingSnapshot) {
		String ret = GlobalConfig.getString("CommonLinkURLs/MeetingSnapshot");
		ret = StringUtils.replace(ret, "{meetingUid}", meetingUid);
		ret = StringUtils.replace(ret, "{meetingSnapshot}", meetingSnapshot);
		return null;
	}

	public static String getThemeEntry(String themeUid) {
		String ret = GlobalConfig.getString("CommonLinkURLs/ThemeEntry");
		ret = StringUtils.replace(ret, "{themeUid}", themeUid);
		return ret;
	}

	public static String getThemeURL(String themeUid, String res) {
		return getThemeEntry(themeUid) + "/" + res;
	}

}
